package netty.InAndOutBundHandler.client;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;

/**
 * @ClassName MyClientInitialzer
 * @Description TODO
 * @Author director吴
 * @Date 2022/4/21 13:29
 * @Version 1.0
 **/
public class MyClientInitialzer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {

        ChannelPipeline pipeline = socketChannel.pipeline();

        //出站 加入Handler  对数据进行编码，再加入一个自定义的Handler处理业务
        //顺序 --> 先走的是自己的Handler,处理完数据。-->再交给编码器进行编码
        pipeline.addLast(new MyLongToByteEncoder());

        pipeline.addLast(new MyClientHandler());

    }
}
